QuickOPC User's Guide and Reference
Examples - OPC Alarms&Events - Browse for servers

.NET

// This example shows how to obtain all ProgIDs of all OPC Alarms and Events servers on the local machine.

using System;
using System.Diagnostics;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.AlarmsAndEvents;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.AlarmsAndEvents._EasyAEClient
{
    class BrowseServers 
    { 
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyAEClient();

            ServerElementCollection serverElements;
            try
            {
                serverElements = client.BrowseServers("");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            foreach (ServerElement serverElement in serverElements)
            {
                Debug.Assert(serverElement != null);
                Console.WriteLine("serverElements[\"{0}\"].ProgId: {1}", serverElement.Clsid, serverElement.ProgId);
            }
        }
    } 
}
' This example shows how to obtain all ProgIDs of all OPC Alarms and Events servers on the local machine.

Imports OpcLabs.EasyOpc
Imports OpcLabs.EasyOpc.AlarmsAndEvents
Imports OpcLabs.EasyOpc.OperationModel

Namespace AlarmsAndEvents._EasyAEClient

    Friend Class BrowseServers
        Public Shared Sub Main1()
            Dim client = New EasyAEClient()

            Dim serverElements As ServerElementCollection
            Try
                serverElements = client.BrowseServers("")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            For Each serverElement As ServerElement In serverElements
                Debug.Assert(serverElement IsNot Nothing)
                Console.WriteLine("serverElements[""{0}""].ProgId: {1}", serverElement.Clsid, serverElement.ProgId)
            Next serverElement
        End Sub
    End Class

End Namespace

COM

Rem This example shows how to obtain all ProgIDs of all OPC Alarms and Events servers on the local machine.

Option Explicit

Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.AlarmsAndEvents.EasyAEClient")
On Error Resume Next
Dim ServerElements: Set ServerElements = Client.BrowseServers("")
If Err.Number <> 0 Then
    WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
    WScript.Quit
End If
On Error Goto 0

Dim ServerElement: For Each ServerElement In ServerElements
    WScript.Echo "ServerElements(""" & ServerElement.UrlString & """).ProgId: " & ServerElement.ProgId
Next

 

See Also

Conceptual

Examples - OPC Data Access